<template>
    <div>
        <!-- 汇总单缴款 -->
        <div class="container">
            <!-- 表单栏 -->
            <el-row class="list-form-container">
                <el-col :span="24">
                    <avue-form v-model="listForm.obj" :option="listForm.option" class="yz-form list-form"></avue-form>
                    <button class="check-btn form-btn rf list-btn" @click="check"><img src="../../assets/imgs/operation_btn_icon_chaxun_default.png" alt="" class="btn-img">查询</button>
                </el-col>
            </el-row>
            <!-- 标题栏 -->
            <el-row>
                <el-col :span="24">
                    <div class="list-title">勾选汇总单合计 (未缴款)</div>
                </el-col>
            </el-row>
            <!-- 缴款信息 -->
            <el-row class="text-container">
                <el-col :span="24">
                    <div class="choose-title lf send-text">汇总单：{{huiSum}} 张</div>
                    <div class="choose-title lf send-text">应缴未缴：{{unpay}} 元</div>
                    <div class="choose-title lf send-text">退票：{{backTic}} 张</div>
                    <div class="choose-title lf send-text">废票：{{abanTic}} 张</div>
                    <button class="check-btn form-btn lf" @click="sendMon"><img src="../../assets/imgs/operation_btn_icon_jiaokuan_default copy.png" alt="" class="btn-img">缴款</button>
                </el-col>
            </el-row>
            <!-- 信息栏 -->
            <el-row>
                <!-- 汇总单列表 -->
                <el-col :span="10">
                    <div class="choose-title list-text">汇总单列表</div>
                    <avue-crud :data="totalList.data" :option="totalList.option" @current-row-change="rowchange"></avue-crud>
                </el-col>
                <!-- 汇总单明细 -->
                <el-col :span="14" class="detail-container">
                    <div class="choose-title list-text">汇总单明细</div>
                    <table class="detail-table" cellspacing="0">
                        <tr>
                            <td class="title-text">售票员</td>
                            <td class="title-text">日期</td>
                            <td class="title-text">汇总单号</td>
                            <td class="title-text">票号段</td>
                            <td rowspan="2">
                                <button class="check-btn form-btn send-btn" @click="send">缴款</button>
                                <button class="check-btn form-btn" @click="print">打印</button>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td class="title-text">售出车票</td>
                            <td class="title-text" colspan="2">售票全部</td>
                            <td class="title-text">取票张数</td>
                            <td class="title-text">非现金营收</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="2">
                                <tr>
                                    <td class="title-text">现金</td>
                                    <td></td>
                                    <td class="title-text">非现金</td>
                                    <td></td>
                                </tr>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td class="title-text">其中售外站票数</td>
                            <td class="title-text" colspan="2">其中售外站金额</td>
                            <td class="title-text">取票金额</td>
                            <td class="title-text">合计营收</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="2">
                                <tr>
                                    <td class="title-text">现金</td>
                                    <td></td>
                                    <td class="title-text">非现金</td>
                                    <td></td>
                                </tr>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td class="title-text">退票张数</td>
                            <td class="title-text" colspan="2">退还金额</td>
                            <td class="title-text">退还手续费</td>
                            <td class="title-text">应缴票款</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="2">
                                <tr>
                                    <td class="title-text">现金</td>
                                    <td></td>
                                    <td class="title-text">非现金</td>
                                    <td></td>
                                </tr>
                            </td>
                            <td></td>
                            <td></td>
                        </tr>
                        <tr>
                            <td rowspan="2" class="title-text">
                                <div>退票明细</div>
                                <div>(票号@退票时间)</div>
                            </td>
                            <td rowspan="2" colspan="4"></td>
                        </tr>
                        <tr>
                        </tr>
                        <tr>
                            <td class="title-text">
                                <div>废票张数</div>
                            </td>
                            <td colspan="4" class="title-text">废票金额</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td colspan="4"></td>
                        </tr>
                    </table>
                </el-col>
            </el-row>
            
        </div>
    </div>
</template>

<script>
import qs from "qs";
import "../../assets/js/jquery.js"
import TableData from "../../components/common/tableData";
import FormData from "../../components/common/form"
const DIC = {
    isSell: [{
        label: '未缴',
        value: 0,
    }, {
        label: '已缴',
        value: 1,
    }],
    seller:[]
}
export default {
  data: function() {
    return {
        listForm:{
            obj:{},
            option:{
                dicData:DIC,
                column:[
                    {
                        label:"售票日期",
                        prop:"sellDate",
                        type:"datetimerange",
                        span:8
                    },
                    {
                        label:"售票员",
                        prop:"seller",
                        type:"select",
                        dicData:"seller",
                        span:5
                    },
                    {
                        label:"是否缴纳",
                        prop:"isPay",
                        type:"radio",
                        dicData: 'isSell',
                        span:8
                    },
                ]
            },
        },
        sendMsg:{},
        totalList:{
            data:[],
            option:{
                menu:false,
                selection: true,
                index:true,
                column:[
                    {
                        label:"售票日期",
                        prop:"create_time"
                    },
                    {
                        label:"售票员",
                        prop:"seller_id"
                    },
                    {
                        label:"售票应缴",
                        prop:"payment"
                    },
                ]
            }
        },
        huiSum:"",
        unpay:"",
        backTic:"",
        abanTic:"",
        currentRow:""
    };
  },
  methods: {
      getSeller(){
          this.postRequest("/sys/user/listWithSpell").then(data=>{
              for(var item of data.data){
                  DIC.seller.push({
                      label:item.name,
                      value:item.id
                  });
              }
          });
      },
      check(){
          this.postRequest("/fin/salesum/list",{
              filterRules:JSON.stringify([
                  {"field":"fin_salesum.create_time","op":"dge","value":this.dateToString(this.listForm.obj.sellDate[0])},{"field":"fin_salesum.create_time","op":"dle","value":this.dateToString(this.listForm.obj.sellDate[1])},{"field":"fin_salesum.seller_id","op":"eq","value":this.listForm.obj.seller},{"field":"fin_salesum.is_payed","op":"eq","value":this.listForm.obj.isPay}
              ])
          }).then(data=>{
              console.log(data);
              this.totalList.data=data.data.list;
          })
      },
      rowchange(val){
          this.currentRow=val;
          this.huiSum=val.lock_count;
          this.unpay=val.sale_sum+val.insurance_sum+val.discount_bill_sum-val.refund_sum_noncash-val.insurance_refund_count-val.payment-val.del_sum;
          this.backTic=val.refund_count;
          this.abanTic=val.del_count;
          this.postRequest("/fin/salesum/salesumDetailPage",{
              id:val.id
          }).then(data=>{
              $(".detail-container").html(data.data);
          });
      },
      sendMon(){
        //   console.log(this.totalList.obj);
          this.getRequest("/fin/salesum/doPayment?id="+this.totalList.selection.join(",")).then(data=>{
              this.msgShow(data,function(){})
          })
      },
      send(){},
      print(){}
  },
  computed: {},
  components:{TableData,FormData},
  watch: {},
  mounted() {
      console.log("汇总单缴款");
      this.$emit("sendActive", "4-2");
      this.getSeller();
  }
};
</script>
<style scoped src="../../assets/css/financeManage/listPay.css">
</style>